<template>
  <!-- <div class="content-box">
  <common-header :title="title" ></common-header>-->
  <div class="page-content">
    <!-- <van-field
      v-model="theme"
      type="text"
      clearable
      label="主题"
      placeholder="请输入主题"
      :required="required"
      :error-message="themeMessage"
    />-->
    <van-field
      v-model="content"
      clearable
      rows="5"
      autosize
      label="邮件内容"
      type="textarea"
      placeholder="请输入邮件内容"
    />
    <van-field
      v-model="msg"
      type="textarea"
      clearable
      rows="5"
      autosize
      label="回复内容"
      placeholder="请输入回复内容"
      required
      :error-message="msgMessage"
    />
    <div class="btnPay" @click="finish()">回复邮件</div>
    <commonFooter></commonFooter>
  </div>
  <!-- </div> -->
</template>
<script>
import { commonFooter } from "common";
import { passwordReg } from "@/utils/regRex";
import { sendMsgRetApi, getOneMsgApi } from "@/api/user";

export default {
  name: "sendretLetter2",
  components: {
    commonFooter
  },
  mounted() {
    if (this.$route.params.token) {
      this.required = false;
      getOneMsgApi({ token: this.$route.params.token }).then(res => {
        if (res.code == 200) {
          this.content = res.data.title;
        }
      });
    }
  },
  methods: {
    finish() {
      let _this = this;
      this.msgMessage = "";

      if (!this.msg) {
        this.msgMessage = "回复内容不能为空";
      } else {
        sendMsgRetApi({
          token:this.$route.params.token,
          msg: this.msg
        }).then(res => {
          _this.$toast({
            message: res.msg,
            duration: 500,
            onClose: function() {
              if (res.code == 200) {
                _this.$router.go(-1);
              }
            }
          });
        });
      }
    }
  },
  data() {
    return {
      msg: "",
      content: "",
      surePassword: "",
      required: true,
      msgMessage: "",
      contentMessage: "",
      surePasswordMessage: ""
    };
  }
};
</script>
<style lang="less" scoped>
@import "~styles/variable.less";
</style>